require('../../assets/css/index.less')
require('../../assets/fonts/iconfont.css')
require('../../lib/weui/weui.css');
require("./badge.less")
let weui = require('../../lib/weui/weui.js');
import * as echarts from 'echarts';
const dom = require('../../utils/dom');
const https = require('../../utils/https');
const local = require('../../utils/local');

dom.ready(function() {
    let html = '';
    let arr = [];
    let name1 = [];
    dom.addevent(".iconfont", function() {
        location.href = "my.html"
    })
    https.get("/api/exercise/badge", function(res) {
        console.log(res);
        let { data, errno } = res;
        if (errno == 0) {
            let id = data.map(v => {
                return v.id
            })
            let name = data.map(v => {
                return v.name
            })
            console.log(id, name);
            // id.forEach((v, x) => {
            //     html += ` <div>
            //     <img src="../../assets/imgs/mybadge0${v}.jpg" alt="">
            //     <p>${name[x]}</p>
            // </div>`
            //     dom.gete("main").innerHTML = html
            // });
            id.forEach((v, x) => {

                arr.push(`mybadge0${v}.jpg`)
                name1.push(name[x])
                local.set('arr', arr);
                local.set('name', name1);
            });
        }
        arr.forEach((v, x) => {
            html += ` <li>
            <img src="../../assets/imgs/${v}" alt="">
            <p>${name1[x]}</p>
        </li>`
            dom.gete("ul").innerHTML = html
        });
    })
})